import { ref } from "vue"

/**日期相关 */
export const sizeDate = ref<"default" | "large" | "small">("default")
// new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 2, 1, 23, 59, 59)
const DATE = new Date()
export const Y = ref<any>(DATE.getFullYear())
export const M = ref<any>(DATE.getMonth())
export const D = ref<any>(DATE.getDate())
export const shortcuts = [
  {
    text: "当天",
    value: () => {
      const end = new Date(Y.value, M.value, D.value, 23, 59, 59)
      const start = new Date(Y.value, M.value, D.value, 0, 0, 0)
      start.setTime(start.getTime())
      return [start, end]
    }
  },
  {
    text: "昨天",
    value: () => {
      const end = new Date(Y.value, M.value, D.value, 23, 59, 59)
      const start = new Date(Y.value, M.value, D.value, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24)
      end.setTime(end.getTime() - 3600 * 1000 * 24)
      return [start, end]
    }
  },
  {
    text: "上周",
    value: () => {
      const end = new Date(Y.value, M.value, D.value, 23, 59, 59)
      const start = new Date(Y.value, M.value, D.value, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 7)
      return [start, end]
    }
  },
  {
    text: "近30天",
    value: () => {
      const end = new Date(Y.value, M.value, D.value, 23, 59, 59)
      const start = new Date(Y.value, M.value, D.value, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 30)
      return [start, end]
    }
  },
  {
    text: "近90天",
    value: () => {
      const end = new Date(Y.value, M.value, D.value, 23, 59, 59)
      const start = new Date(Y.value, M.value, D.value, 0, 0, 0)
      start.setTime(start.getTime() - 3600 * 1000 * 24 * 90)
      return [start, end]
    }
  }
]
